import {getToken} from "@/utils/token";
import {Navigate} from "react-router-dom";
import {message} from "antd";

const AuthRoute = ({children}) => {
    // 判断是否有token进行路由鉴权
    const token = getToken()
    if (token) {
        // 有则返回子组件
        return <>{children}</>
    }else{
        // 没有则跳转到登录页
        message.warning('请登录')
        return <Navigate to='login' replace/>
    }
};
export default AuthRoute